// Author: Bjorn Schobben
#ifndef PROVINCE_H
#define PROVINCE_H

#include "Point.h"
#include "Color.h"
#include "LineSegment.h"
#include <list>
#include <string>



class Province
{
public:
	//Constructors
	Province(const std::string& name);
	Province(const Province& province);

	//Destructor
	virtual ~Province();

	//Delete all allocated contents
	void Clear();

	// Copy another province's contents
	void Copy(const Province& province);

	//Operations on the province color
	virtual void SetColor(Color newColor);
	Color GetColor() const;

	//Operations on the province name
	virtual void SetName(const std::string& name);
	const std::string& GetName() const;

	//Operations on the neighbour list
	void ClearNeighbours();
	void InsertNeighbour(Province& province);

	//Test operations regarding neighbours
	bool IsNeighbouring(const Province& province) const;
	bool NeighbourContainsColor(Color testColor) const;


	// Information about neighbours
	unsigned int NeighbourCount() const;
	unsigned int NeighbourColoredCount() const;

	//Overloaded operators
	bool operator==(const Province& rhs) const;

	// Test if this province contains a point
	bool ContainsPoint(const Point& point) const;

	// Accumulate unique colors to the colorTable
	void GetUniqueColors(std::list<Color>& colorTable) const;

	//Operations on the point list
	std::list<Point*>& GetPoints();
	virtual Point* InsertNewPoint(int x, int y);
	virtual Point* InsertNewPoint(const Point& point);
protected:
	Point* InsertPoint(Point* point);

	//List of the points which determine this province
	std::list<Point*> points;
	//List of the neighbours of this province
	std::list<Province*> neighbours;

private:
	const Point* WrapNextPoint(const std::list<Point*>& pointList, std::list<Point*>::const_iterator& it) const;

	//Color of this province
	Color color;
	//Name of this province
	std::string name;
};

#endif //PROVINCE_H